﻿import React from 'react';
import { Row, Col, Button,Card,Form,Alert,Spin } from 'antd';
import './index.less'
import * as SelectTypes from '../../components/Form/CustomSelect';
import classNames from 'classnames';
import { orderApplyFinish } from '../../actions'

const FormItem = Form.Item;

class SubmitCard extends React.Component {

	constructor(props){
		super(props);
	}

  componentWillUnmount() {
    this.props.dispatch(orderApplyFinish()());
  }

  onNextClick(e) {
    e.preventDefault();
    let { company, profile } = this.props;
    this.props.onNextClick({company, profile});
  }

	render() {
    let { company, profile, loading=false, result } = this.props;
    let alert = null;
    if (result) {
      alert = (
        <Alert
          message="提示"
          description="您的违约信息已经成功提交，请耐心等待审批结果！"
          type="success"
          showIcon
        />
      );
    } else {
      alert = (
        <Alert
          message="注意"
          description="请认真核对以上所填信息，保证信息真实有效！"
          type="info"
          showIcon
        />
      );
    }
		const container = (
		  <div style={{marginTop:24}}>
        {alert}
      <Row gutter={24}>
        <Col span="12">
          <Card title="甲方">
            <p	style={{fontSize: 16,marginBottom:16}}  >{company.orgCode}</p>
            <p style={{fontSize: 16,marginBottom:16}}  >{company.name}</p>
            <p	style={{fontSize: 16,}}  >{company.address}</p>
          </Card>
        </Col>
        <Col span="12">
          <Card title="乙方">
            <p	style={{fontSize: 16,marginBottom:16}}  >{profile.id}</p>
            <p	style={{fontSize: 16,marginBottom:16}}  >{profile.name}</p>
            <p	style={{fontSize: 16,}} label="专业"	 >{profile.majorName}</p>
          </Card>
        </Col>
      </Row>
        <Row type="flex" justify="center" style={{marginTop:24}}>
          <Button type="primary" onClick={this.onNextClick.bind(this)} disabled={result}>提交违约</Button>
          &nbsp;&nbsp;&nbsp;
          <Button onClick={this.props.onLastClick} disabled={result}>上一步</Button>
        </Row>
      </div>
		);

    return (
      <Spin spinning={loading}>{container}</Spin>
    );
	}
}

export default SubmitCard;
